//JSON
var com_genia_toolbox_web_taglib_js_dateFormatToolboxWeb = function () {
	//Regular expressions to handle date format
	var	token        = /d{1,2}|D{1,3}|w{1,2}|M{1,4}|E{1,4}|S{1,3}|yy(?:yy)?|([HhmskKa])\1?|[zZ]|'[^']*'/g,
		pad = function (value, length) {		//Smart display
			value = String(value);
			beginsWithMinus = value.charAt(0) == "-";
			if (beginsWithMinus) {
				value = value.substring(1);
			}
			length = parseInt(length) || 2;
			while (value.length < length) {
				value = "0" + value;
			}
			if (beginsWithMinus) {
				value = "-" + value;
			}
			return value;
		};
		   Date.prototype.getWeek = function () {		//get week on a date
                  var firstJanuary = new Date(this.getFullYear(),0,1);
                  return Math.ceil((((this - firstJanuary) / 86400000) + firstJanuary.getDay()) / 7);
              };
            Date.prototype.getDayOfYear = function() { //get day of year on a date
                var firstJanuary = new Date(this.getFullYear(),0,1);
                return Math.ceil((this - firstJanuary) / 86400000);
              };


	// Regexes and supporting functions are cached through closure
	return function (date, mask, dayNames, monthNames) {	//format date

		var	d = date.getDate(),
			dayOfYear = date.getDayOfYear(),
			D = date.getDay(),
			M = date.getMonth(),
			w = date.getWeek(),
			y = date.getFullYear(),
			H = date.getHours(),
			m = date.getMinutes(),
			s = date.getSeconds(),
			S = date.getMilliseconds(),
			o = -date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				D:    dayOfYear,
				DD:	  pad(dayOfYear),
				DDD:  pad(dayOfYear, 3),
				E:  dayNames[D],
				EE: dayNames[D],
				EEE:dayNames[D],
				EEEE: dayNames[D + 7],
				w:    w,
				ww:   pad(w),
				M:    M + 1,
				MM:   pad(M + 1),
				MMM:  monthNames[M],
				MMMM: monthNames[M + 12],
				y:    String(y).slice(2),
				yy:   String(y).slice(2),
				yyy:  String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				k:	  H || 24,
				kk:	  pad(H || 24),
				K:    H % 12,	
				KK:   pad(H % 12),
				m:    m,
				mm:   pad(m),
				s:    s,
				ss:   pad(s),
				S:	  S,
				SS:	  pad(S),
				SSS:  pad(S, 2),	 	
				a:    H < 12 ? "AM" : "PM",
				z:    o ? "GMT" + (o < 0 ? "" : "+") + pad(o / 60) + ":" + pad(o % 60) : "GMT",
				Z:    (o < 0 ? "" : "+") + pad(o / 60) + "" + pad(o % 60)
			};

		return mask.replace(token, function ($0) {
			return ($0 in flags) ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();